<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <iframe
      src="http://localhost:4000/c.html"
      frameborder="0"
      id="frame"
      onload="load()"
    ></iframe>
  </body>
  <script>
    // a,b同域
    // c独立
    // a获取c的数据

    // a先引用c，c把数据放在window.name
    let first = true;
    function load() {
      let frame = document.getElementById("frame");
      if (first) {
        frame.src = "http://localhost:3000/b.html";
        first = false;
      } else {
        console.log(frame.contentWindow.name); // 拿到通过name拿到c中的数据
      }
    }
  </script>
</html>
